﻿#include <stdio.h>

int adj[4][4] = {
        {0, 0, 0, 0},
        {1, 0, 0, 0},
        {0, 1, 0, 0},
        {0, 1, 0, 0}
};

int main() {
    int visited[4] = {0, 0, 0, 0};
    int degree[4] = {0, 0, 0, 0};
    for (int i = 0; i < 4; ++i) {
        for (int j = 0; j < 4; ++j) {
            if (adj[i][j]) {
                ++degree[j];
            }
        }
    }
    while (1) {
        int u = -1;
        for (int i = 0; i < 4; ++i) {
            if (!visited[i] && !degree[i]) {
                u = i;
                break;
            }
        }
        if (u == -1) break;
        visited[u] = 1;
        printf("%c", 'A' + u);
        for (int i = 0; i < 4; ++i) {
            if (adj[u][i]) {
                --degree[i];
            }
        }
    }
    return 0;
}
